<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Title1</title>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/jquery.easyui.min.js"></script>
    <script src="../js/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="../themes/icon.css">
    <link rel="stylesheet" href="../themes/default/easyui.css">
    <link rel="stylesheet" href="../css/wu.css">
	<script>
		var selectIndex = -1;
	
		function hideTable() {
			$("#searchdiv").toggle();
		}
		$(function() {
			$("#productList").datagrid({
				url : '/kxmanage/sellorderbill/findallcompany',
				pageNumber : 1,
				pageSize : 3,
				pageList : [ 3, 6 ],
				pagination : true,//分页
				checkOnSelect : false,
				columns : [ [ {
					field : 'code',
					title : '客户代号',
					width : 140
				}, {
					field : 'name',
					title : '客户名称',
					width : 180
				}, {
					field : 'type',
					title : '类型',
					width : 70,
					formatter : function(value, row, index) {
						if (row.type == 1) {
							var str = "客户"
						} else if (row.type == 3) {
							var str = "客户/供应商"
						}
						return str;
					}
				}, {
					field : 'linkman',
					title : '联系人员',
					width : 80
				}, {
					field : 'phone',
					title : '电话',
					width : 100
				}, {
					field : 'fax',
					title : '传真',
					width : 100
				}, {
					field : 'address',
					title : '地址',
					width : 180
				} ] ],
				toolbar : '#wu_toolbar'
			});
			
			$("#search_btn").click(function() {
				var form = $("#form1");
				$("#productList").datagrid('load', serializeForm(form));
			});
	
			$('#productList').datagrid({
				onDblClickRow : function(index, row) {
					var name=row.name;
					var linkman=row.linkman;
					var phone=row.phone;
					var fax=row.fax;
					
					var data=new Array();
					data[0]=name;
					data[1]=linkman;
					data[2]=phone;
					data[3]=fax;
					
					parent.bindValue(data);
					
					//$('#productList').datagrid('reload'); 
					//$('#productList').pagination('refresh');
					
 					/* $("#form1").form('reset'); 
					$("#productList").datagrid('load', {});
					setTimeout("parent.closeSon()",20);  */

					
					//和销毁配合使用
					parent.closeSon();
					
				},
				onClickRow:function(index, row) {
					var name=row.name;
					var linkman=row.linkman;
					var phone=row.phone;
					var fax=row.fax;
					var data=new Array();
					data[0]=name;
					data[1]=linkman;
					data[2]=phone;
					data[3]=fax;
					parent.bindValue(data);
				}
			});
	
		});
	
		//将表单序列化
		function serializeForm(form) {
			var obj = {};
			$.each(form.serializeArray(), function(index) {
				if (obj[this['name']]) {
					obj[this['name']] = obj[this['name']] + ',' + this['value']
				} else {
					obj[this['name']] = this['value'];
				}
			});
			return obj;
		}
	</script>
</head>
  
<body>
	<div id="wu_toolbar">
	    <input type="hidden" id="path" value="${pageContext.request.contextPath}"/>
	    <div id="searchdiv" style="display: block;width: 100%;">
	        <form name="form1" id="form1"> 
	            <table width="100%" border="0" cellspacing="0" style="background-color:#c9dfff;" >
	                <tbody><tr>
	                    <td width="70"><b>检索条件:</b></td>
	                    <td width="70" align="right">单位名称:</td>
	                    <td width="150" align="left"><input name="findName" class="easyui-textbox" type="text" id="findName" value="" maxlength="100" style="height:30px"></td>
	                    <td width="70" align="right">单位代号:</td>
	                    <td width="150" align="left"><input name="findCode" class="easyui-textbox" type="text" id="findCode" value="" maxlength="100" style="height:30px"></td>
	                    <td width="70" align="right">单位类别:</td>
	                    <td width="150" align="left">
	                    <select name="findType" id="findType" class="easyui-combobox" style="width:120px;height:30px" panelHeight="150px">
	                    <option value="0">-请选择-</option>
	                    <option value="1">客户</option> 
	                    <option value="3">客户/供应商</option> 
	                    </select>
	                    </td>
	                    <td width="72">
	                        <a id="search_btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
	                    </td>
	                    <td width="72">
	                        <a id="reset_btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-refresh'">重置</a>
	                    </td>
	                    <td width="0"></td>
	                </tr>
	                </tbody>
	            </table>
	            <input type="hidden" id="menuCode" value="100001001">
	        </form>
	    </div>
	</div>
	<div id="productList" class="easyui-datagrid">
	
	</div>
</body>
</html>
